import { get } from '@/utils/request';
import { 
  DashboardOverview,
  UserGrowth,
  UserDistribution,
  RecentActivity,
  SystemPerformance,
  PageView
} from './types';

// 仪表盘相关 API
export const dashboardApi = {
  // 获取仪表盘概览数据
  getOverview: () => get('/dashboard/overview'),

  // 获取用户增长趋势
  getUserGrowth: (period?: '7d' | '30d' | '90d'): Promise<UserGrowth[]> =>
    get<UserGrowth[]>('/dashboard/user-growth', { 
      params: { period } 
    }),

  // 获取用户分布数据
  getUserDistribution: (): Promise<UserDistribution> =>
    get<UserDistribution>('/dashboard/user-distribution'),

  // 获取最近活动
  getRecentActivities: (limit?: number): Promise<RecentActivity[]> =>
    get<RecentActivity[]>('/dashboard/recent-activities', { 
      params: { limit } 
    }),

  // 获取系统性能指标
  getPerformance: () => get('/dashboard/performance'),

  // 获取页面访问统计
  getPageViews: (period?: '7d' | '30d' | '90d'): Promise<PageView[]> =>
    get<PageView[]>('/dashboard/page-views', { 
      params: { period } 
    }),

  getUserActivity: () => get('/dashboard/user-activity'),
  getDepartmentStats: () => get('/dashboard/department-stats'),
  getRoleStats: () => get('/dashboard/role-stats'),
}; 